from django.db import models
from django.utils.timezone import now


class DevicesModel(models.Model):
    id = models.CharField(db_column="c_id", max_length=32, verbose_name=u"主键", primary_key=True, blank=False,
                          null=False)
    device_id = models.CharField(db_column="c_device_id", max_length=100, verbose_name="sn号", blank=True, null=True)
    order_key = models.CharField(db_column="c_order_key", max_length=32, verbose_name="sn号", blank=True, null=True)
    order_id = models.CharField(db_column="c_order_id", max_length=100, verbose_name="sn号", blank=True, null=True)
    mcu_id = models.CharField(db_column="c_mcu_id", max_length=100, verbose_name="mcuid", blank=True, null=True)
    product_number = models.CharField(db_column="c_product_number", max_length=100, verbose_name="品号", blank=True,
                                      null=True)
    product_name = models.CharField(db_column="c_product_name", max_length=100, verbose_name="品名", blank=True,
                                    null=True)
    parameter_file_path = models.CharField(db_column="c_parameter_file_path", max_length=100, verbose_name="配置文件路径",
                                           blank=True,
                                           null=True)
    is_delete = models.BooleanField(db_column="c_is_delete", default=False)
    create_date = models.DateTimeField(db_column="c_create_date", default=now)
    update_date = models.DateTimeField(db_column="c_update_date", default=now)

    class Meta:
        db_table = "t_devices"
        verbose_name = "产品表"
        verbose_name_plural = verbose_name
        ordering = ["-create_date"]


class DeviceVersionModel(models.Model):
    id = models.CharField(db_column="c_id", max_length=32, verbose_name=u"主键", primary_key=True, blank=False,
                          null=False)
    device_id = models.CharField(db_column="c_device_id", max_length=100, verbose_name="sn号", blank=True, null=True)
    version_id = models.CharField(db_column="c_version_id", max_length=100, verbose_name="sn号", blank=True, null=True)
    file_id = models.CharField(db_column="c_file_id", max_length=32, verbose_name=u"主键", blank=False, null=False)
    version_name = models.CharField(db_column="c_version_name", max_length=100, verbose_name="版本名称", blank=False,
                                    null=False)
    version_path = models.CharField(db_column="c_version_path", max_length=100, verbose_name="文件路径", blank=False,
                                    null=False)
    version_auth = models.CharField(db_column="c_version_auth", max_length=100, verbose_name="文件路径", blank=False,
                                    null=False)
    version_msg = models.CharField(db_column="c_version_msg", max_length=100, verbose_name="文件路径", blank=False,
                                   null=False)
    version_date = models.CharField(db_column="c_version_date", max_length=100, verbose_name="文件路径", blank=False,
                                    null=False)
    is_delete = models.BooleanField(db_column="c_is_delete", default=False)
    create_date = models.DateTimeField(db_column="c_create_date", default=now)
    update_date = models.DateTimeField(db_column="c_update_date", default=now)

    class Meta:
        db_table = "t_devices_version"
        verbose_name = "产品表"
        verbose_name_plural = verbose_name
        ordering = ["-create_date"]
